package com.aefan.springcloud.alibaba.controller;

import com.aefan.springcloud.entities.CommonResult;
import com.aefan.springcloud.entities.Payment;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * @Author: jxl
 * @Date: 2021/9/21 上午10:02
 */
@RestController
@Slf4j
public class PaymentController {

    @Value("${server.port}")
    private String serverPort;

    public static HashMap<Long, Payment> hashMap = new HashMap<>();
    static{
        hashMap.put(1L,new Payment(1L,"7s8a87s8a7s8a78a87a87sa8hh10036"));
        hashMap.put(2L,new Payment(2L,"62gs63f09hjds78sh36sg883sjd7hsu"));
        hashMap.put(3L,new Payment(3L,"0s37s75tfh3jl385qj890zbqmq6s009"));
    }

    @GetMapping("/paymentSQL/{id}")
    public CommonResult<Payment> paymentSQL(@PathVariable("id")Long id){
        Payment payment = hashMap.get(id);
        CommonResult<Payment> result = new CommonResult<>(200, "from mysql, serverPort："+serverPort,payment);
        return result;
    }

}
